﻿<ResourceDictionary 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:local="clr-namespace:EasySL.Controls"
  xmlns:sys="clr-namespace:System;assembly=mscorlib"
  >
    <Style TargetType="local:ImageButton">
        <!-- key lines to enable the control -->
        <Setter Property="IsEnabled" Value="true" />
        <Setter Property="IsTabStop" Value="true" />
        <Setter Property="Cursor" Value="Hand" />

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:ImageButton">
                    <Grid x:Name="Root" Margin="0" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
                        <Image x:Name="normalBlock" Source="{TemplateBinding NormalImage}"/>
                        <Image x:Name="hoverBlock" Source="{TemplateBinding HoverImage}" Opacity="0"/>
                        <Image x:Name="clickBlock" Source="{TemplateBinding ClickImage}" Opacity="0"/>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Unfocused"/>
                                <VisualState x:Name="Focused"/>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="00:00:0.5" To="MouseOver"/>
                                    <VisualTransition GeneratedDuration="00:00:0.1" To="Pressed"/>
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="normalBlock" Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:0.3"/>
                                        <DoubleAnimation Storyboard.TargetName="hoverBlock" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.2"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="normalBlock" Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:0.3"/>
                                        <DoubleAnimation Storyboard.TargetName="hoverBlock" Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:0.3"/>
                                        <DoubleAnimation Storyboard.TargetName="clickBlock" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.3"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled" />
                                <VisualState x:Name="Normal" />
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:Loading">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:Loading">
                    <StackPanel x:Name="root" Orientation="Horizontal">
                        <Grid Margin="2">
                            <Image Stretch="None" Source="/EasySL.Controls;component/Images/loading.png" Opacity="0.5" />
                            <Image x:Name="loadingImage" Stretch="None" Source="/EasySL.Controls;component/Images/loading.png" RenderTransformOrigin="0.5,0.5">
                                <Image.RenderTransform>
                                    <RotateTransform Angle="0"></RotateTransform>
                                </Image.RenderTransform>
                            </Image>
                        </Grid>
                        <ContentPresenter x:Name="loadingText" Margin="2" Content="{TemplateBinding Content}"/>
                        <StackPanel.Resources>
                            <Storyboard x:Key="storyboard" x:Name="storyboard">
                                <DoubleAnimation Storyboard.TargetName="loadingImage"  Duration="0:0:0.7" To="360" Storyboard.TargetProperty="(UIElement.RenderTransform).RotateTransform.Angle" RepeatBehavior="Forever"></DoubleAnimation>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="loadingText" Storyboard.TargetProperty="Opacity" RepeatBehavior="Forever">
                                    <SplineDoubleKeyFrame KeyTime="00:00:0.0" Value="0"/>
                                    <SplineDoubleKeyFrame KeyTime="00:00:0.5" Value="1"/>
                                    <SplineDoubleKeyFrame KeyTime="00:00:1.0" Value="0"/>
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>
                        </StackPanel.Resources>
                    </StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:Activity">
        <Setter Property="ActiveContentTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Grid Margin="0,0,0,0" Width="150" HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="Visible" RenderTransformOrigin="0.5,0.5">
                        <Grid.RenderTransform>
                            <TransformGroup>
                                <ScaleTransform/>
                                <SkewTransform/>
                                <RotateTransform/>
                                <TranslateTransform/>
                            </TransformGroup>
                        </Grid.RenderTransform>
                        <Border Background="#FFFFFFFF" BorderThickness="1,1,1,1" CornerRadius="2,2,2,2" Height="51" Margin="0,2,0,0" VerticalAlignment="Top">
                            <Border.BorderBrush>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FFA3AEB9" Offset="0"/>
                                    <GradientStop Color="#FF8399A9" Offset="0.375"/>
                                    <GradientStop Color="#FF718597" Offset="0.375"/>
                                    <GradientStop Color="#FF617584" Offset="1"/>
                                </LinearGradientBrush>
                            </Border.BorderBrush>
                            <Border CornerRadius="1.5,1.5,1.5,1.5" Margin="1,1,1,1">
                                <Border.Background>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="#FFB8B8B8" Offset="0.996"/>
                                        <GradientStop Color="#FFF6F8F9" Offset="0.02"/>
                                    </LinearGradientBrush>
                                </Border.Background>
                                <StackPanel>
                                    <Grid>
                                        <TextBlock HorizontalAlignment="Stretch" Margin="8,4,8,4" VerticalAlignment="Center" FontWeight="Normal" Text="{Binding}" TextWrapping="Wrap"/>
                                        <Image Source="/EasySL.Controls;component/Images/ico_close.png" Stretch="None" HorizontalAlignment="Right" />
                                    </Grid>
                                    <ProgressBar Height="15" Margin="8,0,8,0" IsIndeterminate="True"/>
                                </StackPanel>
                            </Border>
                        </Border>
                    </Grid>
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="DisplayAfter" Value="00:00:00.05" />
        <Setter Property="MinDisplayTime" Value="00:00:00.75" />
        <Setter Property="AutoBind" Value="True" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:Activity">
                    <Grid>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="ActivityDisplay">
                                <VisualState x:Name="Hidden">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Collapsed</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="contentPresenter1" Storyboard.TargetProperty="(UIElement.IsHitTestVisible)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <sys:Boolean>True</sys:Boolean>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="contentControl" Storyboard.TargetProperty="(Control.IsEnabled)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <sys:Boolean>True</sys:Boolean>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Displaying">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="contentPresenter1" Storyboard.TargetProperty="(UIElement.IsHitTestVisible)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <sys:Boolean>False</sys:Boolean>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="contentControl" Storyboard.TargetProperty="(Control.IsEnabled)" Duration="00:00:00.0010000">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <sys:Boolean>False</sys:Boolean>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                                    <Visibility>Visible</Visibility>
                                                </DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
                                            <EasingColorKeyFrame KeyTime="00:00:00" Value="#5AFFFFFF"/>
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <ContentControl x:Name="contentControl"
										VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
										HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}">
                            <ContentPresenter x:Name="contentPresenter1" Canvas.ZIndex="0" Content="{TemplateBinding Content}"/>
                        </ContentControl>
                        <Rectangle x:Name="rectangle" Fill="#32FFFFFF" Canvas.ZIndex="1" Visibility="Collapsed" />
                        <ContentPresenter x:Name="contentPresenter"
                                          Canvas.ZIndex="2" Visibility="Collapsed"
                                          Content="{TemplateBinding Message}"
                                          ContentTemplate="{TemplateBinding ActiveContentTemplate}" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>


